package com.thymeleaf.controller;

import com.thymeleaf.domin.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.NativeWebRequest;

import java.util.ArrayList;
import java.util.List;

/**
 * <h3>thymeleaf</h3>
 * <p></p>
 *
 * @author gdw
 * @since 2024-07-25 09:59:04
 */
@Controller
public class HelloController {
    @RequestMapping("/index")
    public String index(Model model){
        List<Student> list= new ArrayList<Student>();
        model.addAttribute("msg","欢迎");
        Student student = Student.builder().id(1).name("小古").age(18).build();
        Student student1 = Student.builder().id(2).name("小梁").age(18).build();
        list.add(student);
        list.add(student1);
        model.addAttribute("student",student);
        model.addAttribute("list",list);
        return "index";
    }
}
